package com.xiuxia.bopicturebackend.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

@Component
public class StartupRunner implements ApplicationRunner {

    @Value("${server.port:8080}")
    private int port;

    @Value("${server.servlet.context-path:}")
    private String contextPath;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        String address = String.format("http://localhost:%d%s/doc.html", port, contextPath);
        System.out.println();
        System.out.println(" ██████╗ ██╗ ██████╗████████╗██╗   ██╗██████╗ ███████╗");
        System.out.println(" ██╔══██╗██║██╔════╝╚══██╔══╝██║   ██║██╔══██╗██╔════╝");
        System.out.println(" ██████╔╝██║██║        ██║   ██║   ██║██████╔╝█████╗  ");
        System.out.println(" ██╔═══╝ ██║██║        ██║   ██║   ██║██╔══██╗██╔══╝  ");
        System.out.println(" ██║     ██║╚██████╗   ██║   ╚██████╔╝██║  ██║███████╗");
        System.out.println(" ╚═╝     ╚═╝ ╚═════╝   ╚═╝    ╚═════╝ ╚═╝  ╚═╝╚══════╝");
        System.out.println();
        System.out.println("============================================================");
        System.out.println("  应用名称 : bo-picture-backend");
        System.out.println("  启动状态 : ✅ 启动成功");
        System.out.println("  接口文档 : " + address);
        System.out.println("  服务地址 : http://localhost:" + port + contextPath);
        System.out.println("============================================================");
        System.out.println();
    }
}
